package object2.package1;

public class Main {
    public static void eating(Animal animal){
        animal.eat();
    }
    public static void main(String[] args) {
        Cat cat = new Cat();
        cat.setName("小花");
        cat.eat();
        cat.sleep();
        cat.mew();

        Dog dog = new Dog();
        dog.setName("大黄");
        dog.eat();
        dog.sleep();
        dog.bark();

        //多态
        eating(cat);
        eating(dog);

        Animal animal = new Cat();
        animal.setName("狸花猫");
        if(animal instanceof Cat){
            cat = (Cat)animal;
            cat.mew();
        }

        if(animal instanceof Dog){
            dog = (Dog) animal;
            dog.bark();
        }
    }
}
